import ResultWrapper = require('../ResultWrapper')
import RequestResult = require("../RequestResult")
import RequestListResult = require("../RequestListResult")
import BaseModel = require('../BaseModel')
import Order = require('../model/Order')
//code1

//code1

/**
 * 某天的订单列表
 */
class OrderApiListOrderByDate {
    
    get path(): string {
        return '/OrderApi/listOrderByDate'
    }
    
    get isUpload(): boolean {
        return false
    }

    setup(app: any, path: string) {
        console.log('setup service: /' + path)
    }

    //GET
    find(params: any, callback: Function) {
        return this.doWork(params.query)
    }

    doWork(params: any): Promise<any> {

        let page = params.page
        let page_size = params.page_size || RequestListResult.PAGE_SIZE
        /**年月日(如:2017-01-13)*/
        let date: string = params.date


        let callback = (
            resolve: (data: RequestListResult<Order>) => void, 
            reject: (error: Error) => void) => {

            let data = new Order()
            let result = ResultWrapper.wrapList([data])
            result.page = page
            result.page_size = page_size
            result.total_count = 3 * page_size + page_size/2
            result.message = '假数据'

//code2

//code2
            resolve(result)
        }
        return new Promise(callback)
    }
}

export = OrderApiListOrderByDate